/* Copyright (c) 2025 Beijing Semidrive Technology Corporation
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @file  EthIf.c
 * @brief Semidrive. AUTOSAR 4.3.1 MCAL Dummy EthIf plugins.
 */
#ifdef __cplusplus
extern "C" {
#endif

#include "cdefs.h"
#include "EthIf.h"

typedef void (*EthIf_RxCallBack_t)(uint8, Eth_FrameType, boolean, uint8 *, Eth_DataType *, uint16);
typedef void (*EthIf_TxCallBack_t)(uint8, Eth_BufIdxType,Std_ReturnType);

static EthIf_RxCallBack_t Demo_RxCallBack  _SECTION(.dma_buffer);
static EthIf_TxCallBack_t Demo_TxCallBack  _SECTION(.dma_buffer);

void setup_ethif_callback_funciton(void* rxfunc,void* txfunc)
{
    /*PRQA S 0307 2*/
    Demo_RxCallBack = (EthIf_RxCallBack_t)rxfunc;
    Demo_TxCallBack = (EthIf_TxCallBack_t)txfunc;
}

FUNC(void, ETHIF_CODE)EthIf_RxIndication(VAR(uint8, AUTOMATIC) CtrlIdx, \
        VAR(Eth_FrameType, AUTOMATIC) FrameType, \
        VAR(boolean, AUTOMATIC) IsBroadcast, \
        P2VAR(uint8, AUTOMATIC, AUTOMATIC) PhysAddrPtr, \
        P2VAR(Eth_DataType, AUTOMATIC, AUTOMATIC) DataPtr, \
        VAR(uint16, AUTOMATIC) LenByte)
{
    if (Demo_RxCallBack) {
        Demo_RxCallBack(CtrlIdx, FrameType, IsBroadcast, PhysAddrPtr, DataPtr, LenByte);
    }
}



FUNC(void, ETHIF_CODE)EthIf_TxConfirmation(VAR(uint8, AUTOMATIC) CtrlIdx, \
        VAR(Eth_BufIdxType, AUTOMATIC) BufIdx, \
        VAR(Std_ReturnType, AUTOMATIC) Result)
{
    if(Demo_TxCallBack)
        Demo_TxCallBack(CtrlIdx,BufIdx,Result);
}


FUNC(void, ETHIF_CODE)EthIf_CtrlModeIndication( \
        VAR(uint8, AUTOMATIC) CtrlIdx, \
        VAR(Eth_ModeType, AUTOMATIC) CtrlMode \
                                              )
{
    ;
}

#ifdef __cplusplus
}
#endif
